﻿using Architecture.API.Application.TraceabilityCommand.BreedCommand;
using MediatR;
using Traceability.Domain.BreedDomain;
using Traceability.Domain.Service.BreedService;

namespace Architecture.API.Application.TraceabilityCommandHandler.BreedCommandHandler
{
    /// <summary>
    /// 养殖信息显示命令处理器
    /// </summary>
    public class ShowBreedCommandHandler : IRequestHandler<ShowBreedCommand, List<Breed>>
    {
        /// <summary>
        /// 养殖服务
        /// </summary>
        protected readonly IBreedService breedService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="breedService">养殖服务</param>
        public ShowBreedCommandHandler(IBreedService breedService)
        {
            this.breedService = breedService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<Breed>> Handle(ShowBreedCommand request, CancellationToken cancellationToken)
        {
            return await breedService.GetBreedList(request.shoppingId);
        }
    }
}
